const helper = require("../../utils/helper.js");
const userApi = require("../../api/user");

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {
      fans: 0,
      attention: 0,
      visit: 0,
      watch: 0
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // userApi.getCollectionList();
  },

  // 获取用户收藏列表
  getCollectionList: function () {
    helper.showLoading();
    const pack = {
      page: 0,
      type: '1'
    }
    userApi.getCollectionList(pack, (res) => {
      helper.hideLoading();
      console.log(res);
      this.setData({
        collectionList: res && res.data || [],
        isShow: true
      });
    });
  },

  toPage: function (e) {
    const page = e.currentTarget.dataset.page;
    const pages = {
      CARDMANAGE: 'card/mamage',
      ALBUM: 'user/album',
      VIDEO: 'tools/video',
      CONCAT: 'concat',
      CARDMINI: 'card/mini'
    }
    wx.navigateTo({
      url: `/pages/${pages[page]}/index`,
    })
  },

  toVisit: function (e) {
    const type = e.currentTarget.dataset.visitType;
    wx.navigateTo({
      url: `/pages/user/visit/index?type=${type}`,
    })
  },

  toProfile: function () {
    wx.navigateTo({
      url: `/pages/user/profile/index?fromPage=${'user'}`,
    })
  }
})